package com.webtair.dump4j.writer;

import org.apache.log4j.BasicConfigurator;

import org.apache.log4j.Logger;
import org.apache.log4j.helpers.NullEnumeration;

import com.webtair.dump4j.objectdump.ObjectDump;

public class WriterLog4j implements Writer {
	static Logger logger;
	static {
		if(Logger.getRootLogger().getAllAppenders().equals(NullEnumeration.getInstance()))
			BasicConfigurator.configure();
	}
	public WriterLog4j() {
		this(Object.class);	
	}

	public WriterLog4j(Class cl){
	//	BasicConfigurator.configure();
		logger = Logger.getLogger(cl);
		//logger = Logger.getRootLogger();
	}
	public void writeDump(ObjectDump dump){
		String next = dump.firstBlock();
		while(next != null){
			logger.info(next);
			next = dump.nextBlock();
		}
		//logger.info(dump.getStringRepresentation());
	}
}
